#include "ipsocket.h"

int main( int ac, char **av )
{
	ipsocket sock;
	string str1 = av[1];
	string str2 = av[2];
	cout<<str1<<str2<<endl;
    if(str2=="server")sock.creatServer(str1,8877);
    if(str2=="client")sock.creatClient(str1,"192.168.1.116",8877);
        
	char serverdata[10]="12345678\n";
	char clientdata[10]="87654321\n";
	int len=10;

	while(1){
		if(str2=="server"){
			sock.RecvPackets(clientdata,len);
			cout<<clientdata<<endl;
			sock.SendPackets(serverdata,10);
		}
		else{
			sock.SendPackets(clientdata,10);
			sock.RecvPackets(serverdata,len);
			cout<<serverdata<<endl;
		}
		usleep(100000);
	}
	return 0;
}
